package com.hn658.base.message.managermq.test;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.TextMessage;

import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.stereotype.Service;

import com.hn658.base.message.managermq.receive.AbstractMessageListener;
import com.hn658.framework.logging.Logger;
import com.hn658.framework.logging.LoggerFactory;
import com.hn658.framework.logging.enums.LogCategory;

@Service
public class MqMessageListenerManager  extends AbstractMessageListener {


    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(MqMessageListenerManager.class);

    @Override
    public void onMessage(Message message) {

        if(null == message){
            logger.error(LogCategory.SYSTEM, "JMS receive null");
        }else{
            if(message instanceof TextMessage) {
                try {
                    logger.debug("JMS接收消息:{}", ((TextMessage) message).getText());
                } catch (JMSException e) {
                    logger.error("EventBus 接受JMS信息时发生异常:{}", ExceptionUtils.getStackTrace(e));
                }
            }
        }
    }
}
